@extends('default.layouts.adminPublic')
@section('title', '地区分站列表')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/area_station')}}">首页</a> &raquo; 地区分站列表
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->
    <div class="con">
        <div class="conMain">
            <div class="result_wrap">
                <div class="search">
                    <form name="Formso" id="Formso" action="{{url('admin/station_list')}}" method="post">
                        {{csrf_field()}}
                        <span>关键字：</span>
                        <span><input name="keyword" class="keyword" id="keyword" placeholder="请输入地区分站名称" type="text"></span>
                        <span><input name="submit" class="skeyword" value="搜索" type="submit"></span>
                    </form>
                </div>
                <div class="message" style="margin-top: 15px;">
                    <p><span style="margin-right: 20px; font-size: 15px;"><a href="{{url('admin/area_station/create')}}"><i class="fa fa-plus"></i>添加地区分站</a></span>
                        <span>目前共添加<strong>{{count($areaStation)}}</strong>个地区分站！</span>
                    </p>
                </div>

            </div>
            <div class="manage">
                @include('flash::message')
            </div>
            <div class="conInfo">
                <form name="thisForm" id="thisForm" action="" method="post">
                    {{csrf_field()}}
                    <div class="conList" id="conList">
                        <dl class="one">
                            <dt><input name="selectall" type="checkbox" value="1" onclick="CheckAll(this)" /></dt>
                            <dd class="station1">分站子域名</dd>
                            <dd class="station2">分站地区标识</dd>
                            <dd class="station3">分站地区名称</dd>
                            <dd class="station4">分站编码</dd>
                            <dd class="station5">分站排序</dd>
                            <dd class="station6">分站操作</dd>
                        </dl>
                        @if(count($areaStation) > 0 )
                            @foreach($areaStation as $v)
                                <dl id="list{{$v->id}}">
                                    <dt><input name="selected_id[]" type="checkbox" value="{{$v->id}}" /></dt>
                                    <dd class="station1"><a href="{{$v->station_domain}}" target="_blank">{{str_limit($v->station_domain,24)}}</a></dd>
                                    <dd class="station2">{{str_limit($v->station_sign,24)}}</dd>
                                    <dd class="station3">{{str_limit($v->station_name,14)}}</dd>
                                    <dd class="station4">{{$v->station_cid}}</dd>
                                    <dd class="station5">{{$v->station_sort}}</dd>
                                    <dd class="station6">
                                        <span><a href="{{url('admin/area_station/'.$v->id.'/edit')}}">修改地区分站</a></span>
                                        <span><a onclick="delStation({{$v->id}})">删除地区分站</a></span>
                                    </dd>
                                </dl>
                            @endforeach
                        @else
                            <div class="nullcon">对不起！没有地区分站记录！</div>
                        @endif
                        <dl class="last">
                            <dt>
                                <input name="selectall" id="selectall" type="checkbox" value="1" onclick="CheckAll(this)" />
                                <label for="selectall">全选</label>
                            </dt>
                        </dl>
                    </div>
                </form>
                {{--<div class="page_list" style="width: 100%; float: left; margin-top:15px;">--}}
                    {{--{!! $areaStation->links() !!}--}}
                {{--</div>--}}
            </div>

            <div class="stopper" style="margin-top:10px; border-top: 1px solid #e5e5e5"></div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script>
        //全选中与全不选中职位资料
        function CheckAll(form){
            if (form.checked==true){
                for (var i=0;i<document.thisForm.elements.length;i++){
                    var e = document.thisForm.elements[i];
                    if (e.name == 'selectedid' || e.name=='selected_id[]' || e.name=='selectall')
                        e.checked=true;
                }
            }else{
                for (var i=0;i<document.thisForm.elements.length;i++){
                    var e = document.thisForm.elements[i];
                    if (e.name == 'selectedid' || e.name=='selected_id[]' || e.name=='selectall')
                        e.checked=false;
                }
            }
        }
        //删除分站
        function delStation(id) {
            layer.confirm('您确定要删除这个地区分站吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post("{{url('admin/area_station/')}}/" + id, {'_method': 'delete','_token': "{{csrf_token()}}"}, function (data) {
                    if (data.status == 0) {
                        layer.msg(data.msg, {icon: 6,time:1500});
                        $("#thisForm").find('#conList').find("#list"+id).remove();
                    } else {
                        layer.msg(data.msg, {icon: 5,time:1500});
                    }
                });
            });
        }
    </script>
@endsection